<!DOCTYPE html>
<html>

<head>
    <title>倒计时</title>
</head>

<body>
    <input type="datetime-local" id="datetime-local">
    <div id="countdown"></div>

    <script>
        const inputElement = document.getElementById('datetime-local');
        const countdownElement = document.getElementById('countdown');

        setInterval(function () {
            const deadline = new Date(inputElement.value).getTime();
            const now = new Date().getTime();

            const remainingTime = deadline - now;

            const days = Math.floor(remainingTime / (1000 * 60 * 60 * 24));
            const hours = Math.floor((remainingTime % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
            const minutes = Math.floor((remainingTime % (1000 * 60 * 60)) / (1000 * 60));
            const seconds = Math.floor((remainingTime % (1000 * 60)) / 1000);

            countdownElement.innerHTML = `${days} 天 ${hours} 小时 ${minutes} 分钟 ${seconds} 秒`;
            if (remainingTime < 0) {
                clearInterval()
                countdownElement.innerHTML = "已超时";
            }
        }, 1000);

    </script>
</body>

</html>